/**
 * @连接字符串
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

void concat(char result[], const char s1[], const char s2[]);

int main(int argc, char *argv[]) {
	const char s1[] = {"wang "};
	const char s2[] = {"works."};

	char s3[20];

	concat(s3, s1, s2);

	printf("%s\n", s3);
	return 0;
}

void concat(char result[], const char s1[], const char s2[]) {
	int i, j;

	for (i=0; s1[i] != '\0'; i++) {
		result[i] = s1[i];
	}

	for (j=0; s2[j] != '\0'; j++) {
		result[i+j] = s2[j];
	}

	result[i+j] = '\0';
}
